GBML manual / Events

attack_hits

Runs when one of this object’s attack boxes (drawn in the Animations window, on the frame it is showing) touches a body box of an instance of the target object. Inside it, `other` is the instance that was hit. It fires once for each instance hit in each play of the animation, not every frame the boxes touch.

Syntax

attack_hits: Attack hits <object> - fires once per object hit per play of an animation

Description

Runs when one of this object's attack boxes (drawn in the Animations window, on the frame it is showing) touches a body box of an instance of the object you picked, like "Attack hits obj_enemy". Inside it, self is the attacker and other is the instance that was hit.

It runs once for each instance hit in each play of the animation, not on every frame the boxes touch. The exact rule:

Like Collision, it runs after movement and before Step End, in the order of the object list, and it only costs for pairs you write an event for.

Example

instance_destroy(other);

Destroys each enemy the swing reaches, once.

On the GBA

The exact rule: a hit is remembered for the rest of that play of the animation. Starting it again (animation_play(name, true)), a loop coming round again, or a back-and-forth coming back to its first frame is a new play, and the same object can be hit again. An object remembers up to 8 hits per play. A target whose frame has no body box is hit by its collision box. Like Collision, it runs after movement and before Step End, in the order of the object list, and costs only for pairs you write an event for.

See also: Animationsattack_touchingcollisionanimation_play